// 有二段性就可以使用二分查找
class Solution {
    public int peakIndexInMountainArray(int[] arr) {
        int left = 1, right = arr.length - 2;
        while (left < right) {
            int mid = left + (right - left + 1) / 2; // 避免死循环，下面有出现-1，那这里就得+1
            if (arr[mid] > arr[mid-1]) {
                left = mid; // 找小于等于峰顶的值
            } else {
                right = mid - 1;
            }
        }
        return left;
    }
}
